'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.createTable('dish_rating', {
      id: {
        type: Sequelize.BIGINT,
        primaryKey: true,
        autoIncrement: true,
        allowNull: false
      },
      category: {
        type: Sequelize.STRING(100),
        allowNull: false,
        comment: '菜品分类'
      },
      dish_name: {
        type: Sequelize.STRING(255),
        allowNull: false,
        comment: '菜品名称'
      },
      rating_value: {
        type: Sequelize.TEXT,
        allowNull: false,
        comment: '评价值'
      },
      status: {
        type: Sequelize.INTEGER,
        defaultValue: 1,
        comment: '状态 1:有效 0:无效'
      },
      create_time: {
        type: Sequelize.DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      },
      update_time: {
        type: Sequelize.DATE,
        allowNull: false,
        defaultValue: Sequelize.NOW
      },
      deleted: {
        type: Sequelize.INTEGER,
        defaultValue: 0,
        comment: '删除标记 0:未删除 1:已删除'
      }
    });

    // 添加索引
    await queryInterface.addIndex('dish_rating', ['category']);
    await queryInterface.addIndex('dish_rating', ['dish_name']);
    await queryInterface.addIndex('dish_rating', ['status']);
    await queryInterface.addIndex('dish_rating', ['deleted']);
  },

  down: async (queryInterface, Sequelize) => {
    await queryInterface.dropTable('dish_rating');
  }
}; 